<template>
  <view class="payResult" :style="`background-image: url(${getImgSrc()})`">
    <view class="payTitle">{{ result() }}</view>
    <view class="viewWraper">
      <view class="left-btn" @tap="goToSales">返回商城</view>
      <view class="right-btn" @tap="goToNext">{{ nextviewText() }}</view>
    </view>
  </view>
</template>

<script lang="ts">
import "./index.less";
import Taro from "@tarojs/taro";

export default {
  data() {
    return {};
  },
  computed: {
    imgSrc: () => {},
  },
  methods: {
    getResult() {
      const instance = Taro.getCurrentInstance();
      console.log(instance);
      return instance.router.params.result;
    },
    result() {
      const result = this.getResult();
      if (result === "success") {
        return "支付成功";
      }
      return "支付失败";
    },
    getImgSrc() {
      const result = this.getResult();
      if (result === "success") {
        return "https://manbingguanli.oss-cn-beijing.aliyuncs.com/wenduo/1ba26bb3f1254ee791e6295e8643e251pay-success.svg";
      }
      return "https://manbingguanli.oss-cn-beijing.aliyuncs.com/wenduo/7933eda1bbdf44eba3a72b8edd8e534fpay-failed.svg";
    },
    async getTaskList() {},
    async getPersonalHealthyData() {},
    goToNext() {
      const result = this.getResult();
      if (result === "success") {
        return Taro.navigateTo({
          url: "/pages/sales/order/my-order/index",
        });
      }
      return Taro.navigateTo({
        url: "/pages/sales/order/confirm/index",
      });
    },
    nextviewText() {
      const result = this.getResult();
      if (result === "success") {
        return "查看订单";
      }
      return "重新支付";
    },
    goToSales() {
      return Taro.navigateTo({
        url: "/pages/index/index?current=1",
      });
    },
  },

  async created() {
    this.getStepsFromWx();
  },
  mounted() {},

  // onLoad
  onLoad() {},

  // onReady
  onReady() {},

  // 对应 onShow
  onShow() {},

  // 对应 onHide
  onHide() {},

  // 对应 onPullDownRefresh
  onPullDownRefresh() {},
};
</script>
